/*
 * Copyright (c) 2016. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package pw.goyd.game.handler.imp;

import pw.goyd.game.api.DBDone;
import pw.goyd.game.handler.Handler;
import pw.goyd.game.logic.GoldRankListResponse;
import pw.goyd.game.model.Player;
import pw.goyd.protocol.model.Response;

import java.util.List;

/**
 * 金币排行榜响应
 * Created by StanWind on 2016/11/3.
 */
public class GOLDRANK extends Handler {
    @Override
    public void handle() {
        List<Player> players = DBDone.getTopGoldPlayer();
        GoldRankListResponse goldRankListResponse = new GoldRankListResponse();
        goldRankListResponse.setPlayerList(players);
        Response response = new Response();
        response.setCmd(CMD_GOLDRANK);
        response.setData(goldRankListResponse.getBytes());
        response.setTime(0);
        ctx.getChannel().write(response);
    }
}
